package com.study.listener;

import com.study.event.MyEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MyListener4 {

    @EventListener
    @Async  //开启异步，需要加上@EnableAsync
    public void listener(MyEvent myEvent) {
        log.info(String.format("%s监听到事件源：%s.", MyListener4.class.getName(), myEvent.getSource()));
    }
}
